#include "simple.h"

Simple::Simple(const wxString& title)
// : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(350, 250))
	: wxFrame(NULL, -1, title, wxPoint(-1, -1), wxSize(350, 250))
{
	wxImage::AddHandler(new wxPNGHandler);
	wxBitmap exit_(wxT("gtk-quit.png"), wxBITMAP_TYPE_PNG);
	wxToolBar* toolbar = CreateToolBar();
	toolbar->AddTool(wxID_EXIT, wxT("Exit application"), exit_);
	toolbar->Realize();

	menubar = new wxMenuBar;
	file = new wxMenu;
	// file->Append(wxID_EXIT, wxT("&Quit"));
	file->Append(wxID_ANY, wxT("&New"));
	file->Append(wxID_ANY, wxT("&Open"));
	file->Append(wxID_ANY, wxT("&Save"));
	file->AppendSeparator();

	imp = new wxMenu;
	imp->Append(wxID_ANY, wxT("Import newsfeed list..."));
	imp->Append(wxID_ANY, wxT("Import bookmarks..."));
	imp->Append(wxID_ANY, wxT("Import mail..."));

	file->AppendSubMenu(imp, wxT("I&mport"));

	quit = new wxMenuItem(file, wxID_EXIT, wxT("&Quit\tAlt+Q"));
	file->Append(quit);

	menubar->Append(file, wxT("&File"));
	SetMenuBar(menubar);


	wxPanel* panel = new wxPanel(this, wxID_ANY);
	wxButton* button = new wxButton(panel, wxID_EXIT, wxT("Quit"), wxPoint(20, 20));

	// 使用绝对大小，不随缩放而变化
	// textctrl = new wxTextCtrl(panel, -1, wxT(""), wxDefaultPosition, wxSize(250, 150), wxTE_MULTILINE);

	// 使用sizer, 自动缩放
	textctrl = new wxTextCtrl(this, -1, wxT(""), wxPoint(-1, -1));


	Connect(wxID_EXIT, wxEVT_COMMAND_BUTTON_CLICKED,
		wxCommandEventHandler(Simple::OnQuit));
	Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
		wxCommandEventHandler(Simple::OnQuit));
	Connect(wxID_EXIT, wxEVT_COMMAND_TOOL_CLICKED,
		wxCommandEventHandler(Simple::OnQuit));

	// button->SetFocus();
	Centre();
}

void Simple::OnQuit(wxCommandEvent & event)
{
	Close(true);
}